//
//  MajorListViewController.m
//  招生单元包含专业页面
//
//  Created by 唐秦崴 on 15/3/17.
//  Copyright (c) 2015年 Lizzy. All rights reserved.
//

#import "MajorListViewController.h"

@interface MajorListViewController ()

@end

@implementation MajorListViewController

@synthesize majorsListArray = _majorsListArray;
@synthesize unitTitle       = _unitTitle;

-(NSMutableArray*) majorsListArray
{
    if ( !_majorsListArray ) { _majorsListArray = [[ NSMutableArray alloc ] init ];}
    return _majorsListArray;
}

-(NSString*) unitTitle
{
    if (!_unitTitle ) { _unitTitle = @""; };
    return _unitTitle;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 设置返回按钮文字
    // Set this in every view controller so that the back button displays back instead of the root view controller name
    self.navigationItem.backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil];
    
    // 设置返回按钮的颜色
    self.navigationController.navigationBar.tintColor = [ UIColor whiteColor ];
    self.navigationItem.title = self.unitTitle;
    
    // 设置分割线样式
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
    self.tableView.separatorColor = [UIColor colorWithRed:236/255.0 green:208/255.0 blue:191/255.0 alpha:1 ];
    
}


#pragma mark - Table view data source

// tableView每个分区的行数，可以为各个分区设置不同的行数，根据section的值判断即可
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return [ self.majorsListArray count ];
}

// 实现每一行Cell的内容，tableView重用机制
-(UITableViewCell* ) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString* cellIdentifier = @"cellIdentifier";
    
    UITableViewCell* cell = [ tableView dequeueReusableCellWithIdentifier:cellIdentifier ];
    
    if ( nil == cell ) {
        
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    
    cell.textLabel.text  = [self.majorsListArray objectAtIndex:indexPath.row ];
    
    return cell;
}

@end
